<template>
  <iframe ref="iframe" :src='url' frameborder="0" class="iframe"></iframe>
</template>

<script>
import { getClientHeight } from '@/utils'
export default {
  props: [ 'url' ],
  mounted () {
    this.resize()
    this.iframeInit()
  },
  methods: {
    // iframe窗口初始化
    iframeInit () {
      const iframe = this.$refs.iframe
      iframe.style.height = `${getClientHeight() - 90}px`
    },
    // 加载浏览器窗口变化自适应
    resize () {
      window.onresize = () => {
        this.iframeInit()
      }
    },
  }
}
</script>
<style lang="less">
.iframe {
  width: 100%;
  height: 100%;
  border: 0;
  overflow: hidden;
  box-sizing: border-box;
}
</style>
